﻿using System;
using System.Windows.Forms;

namespace TextEditor
{
    

    public class A_CtlMoveUp : A_Action
    {
        public A_CtlMoveUp()
        {
            base.HotKey = Keys.Control | Keys.Up;
        }

        public override string ActionName()
        {
            return "ctlmoveup";
        }

        public override bool Execute()
        {
            if (base.myOwnerDocument.Content.CurrentElement != null)
            {
                ZYTextSelect currentElement = base.myOwnerDocument.Content.CurrentElement as ZYTextSelect;
                if (currentElement == null)
                {
                    currentElement = base.myOwnerDocument.Content.CurrentElement.Parent as ZYTextSelect;
                }
                if (currentElement != null)
                {
                    currentElement.PopupList();
                    return true;
                }
            }
            return false;
        }

        public override bool isEnable()
        {
            if (base.myOwnerDocument.Content.CurrentElement != null)
            {
                ZYTextSelect currentElement = base.myOwnerDocument.Content.CurrentElement as ZYTextSelect;
                if (currentElement == null)
                {
                    currentElement = base.myOwnerDocument.Content.CurrentElement.Parent as ZYTextSelect;
                }
                if ((currentElement != null) && !currentElement.Parent.Locked)
                {
                    return true;
                }
            }
            return false;
        }
    }
}

